package DataStructures.Project3.Group3.s12cs342;

import java.util.ArrayList;


public class QuestionContainer{
 

		private String type, question, correctAnswer;
       
        private int pointsWorth;
       
        @SuppressWarnings("rawtypes") private String[] answers;
       
        private String TFAnswer;
       
        /**
         * Constructor to create any of the current question styles
         *
         * @param type - 0, 1, or 2 for Multiple Choice, True or False, or Short answer respectively
         * @param question - The question to be asked
         * @param answers - Possible answers (Only needed for Multiple Choice, null in other styles)
         * @param correctAnswer - The correct answer to the question
         */
        @SuppressWarnings({ "unchecked", "rawtypes" })
        public QuestionContainer(int type, String question, ArrayList<String> answers, String correctAnswer, int pointsWorth){
               this.answers = new String[answers.size()];
                switch (type){
                case 0: this.type = "Multiple Choice";
                                this.question = question;
                                this.answers = answers.toArray(new String[answers.size()]);
                                this.correctAnswer = correctAnswer;
                                this.setPointsWorth(pointsWorth);
                                break;
                case 1: this.type = "True or False";
                                this.question = question;
                                this.answers[0] = ("true");
                                this.answers[1] = ("false");
                                if (correctAnswer.equals("True")){
                                        this.TFAnswer = "True";
                                }else{
                                        this.TFAnswer = "False";
                                }
                                this.setPointsWorth(pointsWorth);
                                break;
                case 2: this.type = "Short Answer";
                                this.question = question;
                                this.answers = null;
                                this.correctAnswer = correctAnswer;
                                this.setPointsWorth(pointsWorth);
                                break;
                default:System.err.println("Bad question type: " + type + ". Only 0, 1, and 2 are currently useable");
                                break;
                       
                }
        }

       
      

		public String getType() {
                return type;
        }

        public void setType(String type) {
                this.type = type;
        }

        public String getQuestion() {
                return question;
        }

        public void setQuestion(String question) {
                this.question = question;
        }

        public String getCorrectAnswer() {
                return correctAnswer;
        }

        public void setCorrectAnswer(String correctAnswer) {
                this.correctAnswer = correctAnswer;
        }

        @SuppressWarnings("rawtypes")
        public String[] getAnswers() {
                return answers;
        }

        @SuppressWarnings("rawtypes")
        public void setAnswers(ArrayList<String> answers) {
                this.answers = (String[]) answers.toArray();
        }

        public String isTFAnswer() {
                return TFAnswer;
        }

        public void setTFAnswer(String tFAnswer) {
                TFAnswer = tFAnswer;
        }

        public int getPointsWorth() {
                return pointsWorth;
        }

        public void setPointsWorth(int pointsWorth) {
                this.pointsWorth = pointsWorth;
        }
       
        /**
         * A method to get the int representation of a question type.
         *
         * If -1 is returned the String do not match a question type.
         *
         * @param type - The String type of the question
         * @return - The integer that is related to that type
         */
        public int getQuestionIntType(String type){
                if (type.equals("Multiple Choice")){
                        return 0;
                }else if (type.equals("True or False")){
                        return 1;
                }else if (type.equals("Short Answer")){
                        return 2;
                }else{
                        return -1;
                }
        }
       
        /**
         * A method to get the related String Type from an int.
         *
         * @param type - int of the type
         * @return - the string name of the related Type or an error message
         */
        public String getQuestionStringType(int type){
                switch(type){
                case 0: return "Multiple Choice";
                case 1: return "True or False";
                case 2: return "Short Answer";
                default: return "Currently only 0 through 2 represent question types";
                }
        }

		public int describeContents() {
			// TODO Auto-generated method stub
			return 0;
		}

		
}
